<!--/**-->
<!-- * Created by PhpStorm.-->
<!-- * User: liuhui-->
<!-- * Date: 2016/9/27-->
<!-- * Time: 15:34-->
<!-- */-->
<extend file='resource/view/master'/>
<block name="content">
    <style>
        th{
            text-align: center;
        }
    </style>
    <ol class="breadcrumb" style="background-color: #f9f9f9;padding:8px 0;margin-bottom:10px;">
        <li>
            <a href=""><i class="fa fa-cogs"></i>
                类型管理</a>
        </li>
        <li class="active">
            <a href="">属性列表</a>
        </li>

    </ol>
    <ul class="nav nav-tabs" role="tablist">
        <li class="active"><a href="{{u('Typeattr.index',['tid'=>$tid])}}">属性管理</a></li>
        <li><a href="{{u('Typeattr.add',['tid'=>$tid])}}">添加属性</a></li>
    </ul>
    <form action="" method="post">
        <div class="panel panel-default">
            <div class="panel-body">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>属性ID</th>
                        <th>属性名称</th>
                        <th width="120">属性类别</th>
                        <th width="550">属性值</th>
                        <th>所属类型</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <foreach from="$data" key="$k" value="$v">
                    <tr style="text-align: center">
                        <td>{{$v['taid']}}</td>
                        <td>{{$v['taname']}}</td>
                        <if value="$v['class']==1">
                            <td>
                                属性
                            </td>
                        <else>
                            <td>
                                规格
                            </td>
                        </if>

                        <td>
                            {{$v['tavalue']}}
                        </td>
                        <td>
                            {{$tname}}
                        </td>
                        <td>
                            <div class="btn-group">
                                <button data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span></button>
                                <ul class="dropdown-menu dropdown-menu-right">
                                    <li><a href="{{u('Typeattr.edit',['taid'=>$v['taid']])}}">编辑</a></li>
                                    <li class="divider"></li>
                                    <li><a href="{{u('Typeattr.del',['taid'=>$v['taid'],'tid'=>$tid])}}" onclick="del({{$v['cid']}})">删除</a></li>
                                </ul>
                            </div>
                        </td>
                    </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
        </div>
    </form>
    <div class="pagination pagination-sm pull-right">
    </div>
</block>
<script>
    function edit(tid){
        var data = $('#form').serialize();
        //res返回的数据：{valid:0,message:'提示信息'}
        $.post("{{u('edit')}}",data,function(res){
            if(res.valid)
            {//成功
                //参数：提示消息，跳转地址，成功/失败
                util.message(res.message,"{{u('index',['tid'=>tid])}}",'success');
            }else{
                util.message(res.message,"",'error');
            }
        },"json")
        return false;
    }
</script>